package dao;

import model.BusinessType;
import util.Util;

import javax.xml.transform.Result;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class BusinessTypeDao {
    public List<BusinessType> findAllTypes() {
        List<BusinessType> list = new ArrayList<BusinessType>();
        Connection con = null;
        try {
            con = Util.getConnection();
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery("select * from businessType");
            while (rs.next()){
                BusinessType bt=new BusinessType(rs.getInt("id"),rs.getString("Name"),rs.getString("img"));
                list.add(bt);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                Util.closeConnection(con);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return list;
    }

}